package 力扣;

import java.util.HashMap;
import java.util.Set;

/**
 * @author yyq
 * @create 2022-03-13 19:25
 */
public class leetcode242 {
    public static void main(String[] args) {

    }
    public boolean isAnagram(String s, String t) {
        if(s.length()!=t.length()) return false;
        HashMap<Character,Integer> Smap=new HashMap<>();
        HashMap<Character,Integer> Tmap=new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            char c=s.charAt(i);
            char b=t.charAt(i);

            if(Smap.containsKey(c)==false) Smap.put(c,1);
            Smap.put(c,Smap.get(c)+1);


            if(Tmap.containsKey(b)==false) Tmap.put(b,1);
            Tmap.put(b,Tmap.get(b)+1);

        }

        if(Smap.size()!=Tmap.size()) return false;
        for (Character character : Smap.keySet()) {
            if(Tmap.containsKey(character)==false) return false;
            if(Tmap.get(character).equals(Smap.get(character))==false) return false;
        }
        return true;

    }
}
